home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / shells / kiss-0.11 / kiss-0 / kiss / doc / userguide.txt < prev   
Text File  |  1995-04-19  |  14KB  |  312 lines

  1.  
  2.                 K I S S   User Guide
  3.  
  4.  
  5. Starting Kiss
  6. -------------
  7.  
  8. Kiss supports a lot of flags. Try "[brg]kiss -h" if you want to see the list.
  9. The executable that you want to start is either "bkiss", "gkiss" or "rkiss", I
  10. suggest "rkiss" if you have all of them (you have now, since you've unpacked
  11. the archive).  The "bkiss" version ("b" for "bare") has no line editing
  12. facilities, but is the smallest - so it's ideal for a rescue disk. The "gkiss"
  13. program has getline support, it has line editing. The "rkiss" finally has line
  14. editing and filename completion. Supported flags by all the Kiss programs are,
  15. e.g., "-c command" to run a command, or "file [file..]" to load scripts.  
  16.  
  17. Mostly, you'll want Kiss just started in interactive mode, without any flags.
  18. To get a feel for how things work, try "help". If too much info scrolls off
  19. the screen, try "help | more". That will show all the built-in commands and an
  20. overview of relevant environment settings.
  21.  
  22. A handy thing to keep in mind: most built-in commands recognize the "-h" flag.
  23. If you want to know how the built-in "ls" works, try "ls -h".
  24.  
  25.  
  26. The command parser
  27. ------------------
  28.  
  29. Kiss has an input parser which works as follows. I'm just describing some of
  30. the highlights here, so that you know.
  31.  
  32.     The input consists of one or more lines. You can terminate Kiss by
  33.     stopping the input: either send an EOF character (^D) or type "exit" (or,
  34.     "exit 3" if you want exit status 3). See the info which the "help" command
  35.     provides about "exit". (Note: the getline version requires you to type ^D
  36.     twice to exit, it's some quirk.)
  37.  
  38.     Each line consists of statements, separated by pipe tokens and terminated
  39.     by a newline token. Which means that the command will be interpreted as
  40.     soon as you hit enter (what did you expect). The pipe tokens work in the
  41.     normal fashion: "a | b | c | d" will start four programs, "a" to "d",
  42.     where each next program receives on its standard input the output of the
  43.     previous program. The output of "d" (if any) goes to the screen, the input
  44.     of "a" (if any) comes from the keyboard. Kiss doesn't understand piping of
  45.     other streams than stdin and stderr. Standard-error messages will always
  46.     appear on screen. Furthermore, the parser understands the "&" character
  47.     when it appears as the last thing on the input line. Note that "&" marks
  48.     may not appear elsewhere.
  49.  
  50.     Besides the newline-terminator, Kiss knows about the ";" character. E.g.,
  51.     "ls ; ls" will run two "ls" commands for you. The ";" character is handy
  52.     in aliases (described later), but in interactive mode it's just like
  53.     typing a newline. Incidentally, this means that if you want a 'real'
  54.     semicolon (e.g., as an argument to the "find" program), you must `protect'
  55.     it by quoting it; as in:
  56.             prompt>  find / -exec ls {} ';'
  57.     Quoting special characters is always done with single or double quotes,
  58.     the same reasoning holds for pipe tokens "|" and redirections "<" etc..
  59.  
  60.     A statement (i.e., info between the "|" marks or just the strings when no
  61.     piping is needed) is either the `recall' command or a `real' command. The
  62.     recall command is very handy: those familiar with Tcsh surely know it. It
  63.     recalls a command from the "history list". E.g., "!d" re-runs the last
  64.     command that starts with "d". Another history-related command is
  65.     "history", which shows what your previous commands are. Try "history |
  66.     more" if the list is getting long. If you find typing "history" too much,
  67.     try "alias his history" and then "his | more". Or even: 
  68.     "alias mhis 'history | more'" , and then "mhis".
  69.  
  70.     Commands which don't recall previously entered commands may be followed by
  71.     "< file" and/or "> file" or ">> file", forcing redirection of stdin or
  72.     stdout to a file. Kiss doesn't support redirection of stderr.
  73.  
  74.     In the end, commands are just strings. Kiss knows four types of strings:
  75.  
  76.     a. Simple strings are just what they are, e.g. names of program files.
  77.        Simple strings are subject to expansion of wildcards (e.g., *.c
  78.        becomes a lot of strings) etc.
  79.  
  80.     b. Quoted strings are enclosed by " or '. Such strings aren't subject
  81.        to expansion. This is the way to protect `special' characters like
  82.        pipe tokens, semicolons or "<" and ">".
  83.  
  84.     c. Backquoted strings are enclosed by `. These are substituted with
  85.        the output of a program; e.g. "echo `ls`". 
  86.  
  87.     d. Variables are in the form $STUFF. Note that Kiss only knows of
  88.        variables which are named in upper case. Also note that Kiss
  89.        doesn't understand variable names in the form ${STUFF}.
  90.  
  91.     Strings which contain "~/" are rewritten so that the tilde is expanded to
  92.     the user's home directory. E.g, when you type "cd ~/bin" then you
  93.     change-dir to "$HOME/bin".
  94.  
  95.  
  96. Environment access
  97. ------------------
  98.  
  99. Kiss has four commands which access the environment.
  100.  
  101.     a. "printenv" shows the environment in a series of lines "VAR=value". You
  102.        can also look for only one environment string, e.g. "printenv PATH".
  103.     b. "setenv VAR value" sets the environment variable "VAR" to "value. E.g.,
  104.         prompt>  setenv PATH $PATH:/usr/local/bin
  105.        adds "/usr/local/bin" to the search path.
  106.     c. The syntax "VAR=value" is a synonym for "setenv". Spaces are allowed;
  107.        "VAR = value" is the same as "VAR=value".
  108.     d. The command "unsetenv VAR" removes the "VAR" from the environment.
  109.  
  110. Of course, you can type "$VAR" to get the value of a variable, as in
  111.         prompt> echo $PATH
  112.  
  113. Relevant environment variables are:
  114.  
  115.     a. $PATH is of course the search-path for programs. A handy command here
  116.        is "where", e.g., try "where ls". It will show that "ls" is a built-in
  117.        command but also resides in "/bin/ls".
  118.     b. $HOME is set by Kiss to the user's home directory.
  119.     c. $PWD is maintained by Kiss and always holds the current working
  120.        directory. The command "pwd" prints it.
  121.     d. $SHELL is the name of the shell interpreter, e.g.
  122.        "/usr/local/bin/kiss".
  123.     e. $SHLVL is the shell level: initially "1". As Kiss forks to start
  124.        programs, $SHLVL is incremented. This variable is mainly for internal
  125.        use.
  126.     f. $UID is the numerical user ID, $USER is the user name (when available).
  127.     g. $PROMPT tells Kiss what to display as the input prompt. You can put
  128.        special characters in the setting:
  129.         %p gives the current working directory,
  130.         %u gives the username,
  131.         %n gives a newline.
  132.        The default $PROMPT is "[%u] %p > ", which gives something like
  133.        "[username] /tmp > " as the prompt.
  134.     h. $$ is the shell's process ID.
  135.     i. $? is the last command's exit status.
  136.     j. $! is the last command's process ID.
  137.     
  138.  
  139. Aliases
  140. -------
  141.  
  142. Kiss understands a special command called "alias", to set up an alias for
  143. a command. Example:
  144.  
  145.     prompt> alias d  ls -Fla
  146.     prompt> d                    # this runs "ls -Fla"
  147.     prompt> d /tmp                # this runs "ls -Fla /tmp"
  148.  
  149. If you postfix any arguments to an alias (as in "d /tmp"), then those
  150. arguments will be postfixed to the expanded command (giving "ls -Fla /tmp").
  151.  
  152. You can mention arguments in aliases, use $1, $2 etcetera. E.g.:
  153.  
  154.     prompt> alias dx  'ls -l *.$1'
  155.     prompt> dx c                # this runs "ls -l *.c"
  156.  
  157. Here you need to mention "$1" explicitely because you want that argument to be
  158. appended to "ls -l *." without spaces in between.
  159.  
  160. This way you control where arguments exactly appear in an alias. Another handy
  161. alias for X users:
  162.  
  163.     prompt> alias xvi 'xterm -e vi $1 &'
  164.     prompt> xvi somefile            # runs xterm -e vi somefile &
  165.  
  166. Here you need to mention "$1" explicitely because following the argument you
  167. want the "&" character.
  168.  
  169. The "alias" command can also list aliases (when invoked without arguments) or
  170. a particular alias (when invoked with one argument). Once you invoke "alias"
  171. with two or more arguments, you're defining a new alias or redefining an old
  172. one.
  173.  
  174. I call aliases which invoke more than one command `chained aliases'. E.g.:
  175.  
  176.     prompt> alias go 'a ; b'
  177.     prompt> go                # this runs first "a", then "b"
  178.  
  179. Kiss only understands simple alias chaining, so beware. Some restrictions are:
  180.  
  181.     a. The commands in a chained alias must be separated by a ; in spaces. So:
  182.     prompt> alias go 'a;b'        # won't work, you need 'a ; b'
  183.        You really need the space before AND after the semicolon. This
  184.        requirement is btw. only true in aliases, the semicolon doesn't need
  185.        spaces around it when you enter it interactively. (It's not a perfect
  186.        world..)
  187.  
  188.     b. Chained aliases may only consist of two commands, not more. E.g.:
  189.     prompt> alias go 'a ; b ; c'        # won't work, three commands
  190.       To run three commands via an alias, you need an intermediate alias:
  191.     prompt> alias go    'a ; go_1'
  192.     prompt> alias go_1    'b ; c'
  193.     prompt> go                # now this runs a, b and then c
  194.  
  195.     c. The second command in an alias isn't passed arguments, you just can run
  196.        it `bare'.
  197.  
  198.  
  199. Startup files
  200. -------------
  201.  
  202. Kiss tries to load two startup files, one system-wide resource and one
  203. user-owned resource. The files are:
  204.  
  205.     a. /etc/kiss.rc : system-wide file
  206.     b. ~/.kissrc    : user-owned file
  207.  
  208. You can put anything in the startup files, including "cd" commands, "echo", or
  209. whatever. The files are however typically used for auto-loading aliases.
  210.  
  211. Here's a favorite of mine, which you can put into your ~/.kissrc:
  212.  
  213.     # my favorite editor
  214.     EDITOR = jove
  215.  
  216.     # how to re-read ~/.kissrc
  217.     alias reload    source ~/.kissrc
  218.  
  219.     # how to edit ~/.kissrc and re-read it immediately
  220.     alias ek        '$EDITOR ~/.kissrc ; reload'
  221.  
  222.  
  223. The built-in commands
  224. ---------------------
  225.  
  226. Here follows a brief description of the built-in commands. Most of them will
  227. work as expected; I'm just focusing on the differences.
  228.  
  229. A handy command to find out whether a command is a built-in is "where"; e.g.,
  230. "where mount" will show where an external "mount" program resides and that
  231. "mount" is an internal command. If you prefer to start the external command
  232. instead of the internal one, just type the full name (say "/sbin/mount")
  233. instead of just "mount".
  234.  
  235.     "cat": Doesn't support buffer sizes or what else you need. Just prints
  236.     stdin or a file to stdout.
  237.  
  238.     "chmod": You can use here mode strings like "a+x" (for all: add execute
  239.     bit), or octal numbers (644 for owner: r/w, group: r, others: r). The
  240.     mode strings however don't know about sticky or setuid bits, just
  241.     r/w/x. Use octal modes to set or clear s-bits.
  242.  
  243.     "chown": Just changes the owner, you can't change both owner and group
  244.     with one command. Use "chgrp" to change group ownership.
  245.  
  246.     "cp": Is pretty clever, copies files while preserving `holes'. This means
  247.     unfortunately that "cp" is slow. Needs rewriting.  Furthermore, "cp"
  248.     only copies _files_, not pipes or devices. Use "mknod" to create
  249.     devices. "cp" does know about symlinks though, it will copy links if
  250.     you give it the "-d" flag.
  251.  
  252.     Also, "cp" may not synthesize destination pathnames as you're used to.
  253.     I never figured out the original "cp" anyway.
  254.  
  255.     "grep": Just a subset of the real "grep", though it understands true
  256.     regular expressions. Only supports "-i" (ignore case) and "-v" (show
  257.     non-matching lines) flags.
  258.  
  259.     "kill": Doesn't support symbolic names for signals (e.g. "-HUP"). Just the
  260.     numbers.
  261.  
  262.     "ln": Always requires that the link to create doesn't exist, you cannot
  263.     overwrite files with new links. Not even with the "-f" flag. The "ln"
  264.     command interprets its "-f" flag a bit off: for me it means "create a
  265.     link even if it points nowhere". Hm.
  266.  
  267.     "ls": Output in columns is sorted left-to-right, while the original "ls"
  268.     sorts top-to-bottom. I don't intend on fixing that. Also, dates and
  269.     times are displayed a bit non-standard with "ls -l".
  270.  
  271.     "mknod": Always creates pipes or devices with octal mode 644. There's no
  272.     "--mode" flag. Use "chmod" to adjust the mode.
  273.  
  274.     "more": No page-back commands, and you must hit ENTER after each input.
  275.     Always pauses after 23 lines of output. Doesn't recognize too long
  276.     lines.
  277.  
  278.     "mount": Doesn't update /etc/mtab, so you can't get a listing of what's
  279.     mounted and what not. Also doesn't inspect /etc/fstab so that you
  280.     never can mount all. Doesn't support read/only mounting.
  281.  
  282.     "setenv" and its alias "VAR=value": Only knows about variables in upper
  283.     case. You can't make variables in lower case.
  284.  
  285.     "source": Doesn't check `circular' sourcing, you could e.g. source file
  286.     "a" which contains "source b", so that "b" is sourced, but if "b"
  287.     sources "a" again then you have an endless loop.
  288.  
  289.     "touch": Only sets file times to the current time.
  290.  
  291.     "wc": The word counting is a bit off, I couldn't figure out what the
  292.     orginal "wc" considers one `word'. The line and character counts are
  293.     ok though.
  294.  
  295.  
  296. Signal handling
  297. ---------------
  298.  
  299. Kiss will try to stay alive as long as possible. I know that the program isn't
  300. perfect: if it is signalled with a segmentation fault, it tries to reload. I
  301. know that this is non-standard, but I want to provide some interpreter access
  302. when things go haywire. Other signals which are caught by Kiss are:
  303.  
  304.     a. 10 and 12; SIGUSR1 and SIGUSR2. Kiss will try to reload when you send
  305.        it this signal. E.g., try
  306.                 prompt> kill -10 $$
  307.     b. Signal 2 (SIGINT, sent when you type ^C) is by default ignored. Start
  308.        Kiss with the "-C" flag if you want Kiss to abort with ^C.
  309.     c. Other signals have the default action; e.g., signal 15 will kill Kiss.
  310.        (Signal 9 will too ;-).
  311.        
  312.